package hello;

import java.io.IOException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cn.hutool.http.HttpUtil;

@RestController
public class GreetingController {

  

    @RequestMapping("/greeting")
    public String greeting(@RequestParam(value="name", defaultValue="World") String name) throws IOException {
    	
      Object object =   HttpUtil.get(API.getUrl(),Sign.getSignature(Sign.getKeybyvalue(name), "你的密钥"));
      System.err.println("我说："+name+"Lindas说："+object.toString());
      JSONObject jsonObject = JSONObject.parseObject((String) object);
		Respost respost = JSON.toJavaObject(jsonObject, Respost.class);
		
        // return  jsonObject.toJSONString();
		return respost.getAnswer();
    }
}
